home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 414 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.2 KB  |  72 lines

  1. Path: news.mountain.net!usenet
  2. From: gene_heskett@wvlink.mpl.com (Gene Heskett)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: Is this a SAS/C bug or have I coded it wrong?
  5. Date: 7 Jan 1996 17:57:00 GMT
  6. Organization: MountainNet, Inc. Morgantown WV 800.444.1458
  7. Message-ID: <1784.6580T49T1764@wvlink.mpl.com>
  8. References: <4cfrc5$gsc@misery.millcomm.com>
  9. NNTP-Posting-Host: slip3.mpl.com
  10. X-Newsreader: THOR 2.22 (Amiga;TCP/IP)
  11.  
  12.  Y> Is this a SAS/C bug or am I getting more blind???
  13.  
  14.  Y> ======================================================================
  15.  Y> === The following code:
  16.  Y> ======================================================================
  17.  Y> ===
  18.  
  19.  Y>    tmpbuf[10];
  20.  
  21.  Y>    int
  22.  Y>    test( void )
  23.  Y>    {
  24.  
  25.  Y>       if ( tmpbuf[0] & 0x1f == 1 )
  26.  Y>          return 1;
  27.  
  28.  Y>       return 0;
  29.  Y>    }
  30.  
  31.  Y> ======================================================================
  32.  Y> === Produces:
  33.  Y> ======================================================================
  34.  Y> ===
  35.  Y>                  SECTION      text,CODE
  36.  Y>    __code:
  37.  Y>    test:
  38.  Y>    ___test__1:
  39.  Y>                  MOVEQ.L        #$0,D0                   ;7000 
  40.  Y>    ___test__2:
  41.  Y>                  RTS                                     ;4e75 
  42.  Y>    __const:
  43.  Y>    __strings:
  44.  Y>                  XDEF           test
  45.  Y>    
  46.  Y>                  SECTION        __MERGED,BSS
  47.  Y>    __MERGEDBSS
  48.  Y>    tmpbuf:
  49.  Y>                  DS.B           40
  50.  Y>                  XDEF           tmpbuf
  51.  Y>                  END
  52.  Y> ======================================================================
  53.  Y> === Is this right?  Where'd the "IF" go?  Do I have it coded wrong?
  54.  
  55.  
  56.  Y>    if ( tmpbuf[0] & 0x1f == 1 )
  57.  
  58. Well, while your code *may* be legal, I think what you wanted was:
  59.        if ( (tmpbuf[0] & 0x1f) == 1 )
  60. which could be simplified to:
  61.        if (tmpbuf[0] & 0x01)
  62. since you are asking in fact if the least significant bit is set.
  63. But I don't claim to be a guru.
  64.  
  65.  
  66. /*            Gene Heskett          |  These opinions are NOT to be  */
  67. /*  CE @ WDTV Weston/Clarksburg WV  |  confused with the official    */
  68. /*  <gene_heskett@wvlink.mpl.com>   |  WDTV managment views          */
  69. #include <std.disclaimer>
  70.  
  71.  
  72.